******************************************
*
*	Article: The Human Costs of the War on Drugs: Attitudes towards Militarization of Security in Mexico
*	Authors: Juan Masullo J., Davide Morisi
*	Journal: Comparative Political Studies
*	Date: 23 March 2023
*
*	This file replicates the following
*	ANALYSIS OF STUDY 2 - APPENDIX B + Figure 3 in main paper
*
*	All analyses performed with Stata/SE 14.2 for Windows
******************************************

*Set working directory
*[my working directory]

*Open original dataset without potential identifiers Study 2
use "Replication_CPS\Data\study2_recoded.dta", clear

*Covariates
global demo_st2 "i.female age10 ib2.ed_level5 trust_army01 i.regions"


*
*Table B1. Summary statistics
gen dv_att_group8 = dv_att if group==8
tab ed_level5, gen(edu_cat)
tab regions, gen(region_cat)
tab group, gen(group_cat)
*table
eststo clear
estpost sum dv_att dv_att_group8 female age edu_cat* victim_cartel trust_army01 hom_1317_pop hom_1317_pop_w cartel_total2017 region_cat* group_cat*
esttab using "~TableB1.rtf", cells("count mean sd min max") replace
*drop created var
drop dv_att_group8 edu_cat* region_cat* group_cat*

*
*Table B2. Correlates of support for militarization
eststo clear
eststo: reg dv_att i.female age10 ib2.ed_level5 i.victim_cartel hom_1317_pop_w cartel_total2017 i.group i.regions 
eststo: reg dv_att i.female age10 ib2.ed_level5 i.victim_cartel hom_1317_pop_w cartel_total2017 polspectr i.pid5 trust_army01 i.group i.regions
esttab using "~TableB2.rtf", ///
b(%6.3f) se(%6.3f) starlevels(+ .1 * .05 ** .01 *** .001) scalars (r2) title("TableB2. Study 2 - Correlates of support for militarization") wide compress noeqlines replace 

*
*Table B3. Balance tests
eststo clear
mlogit group $demo_st2 i.victim_cartel, b(1)
esttab using "~TableB3.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) title("TableB3. Study 2 - balance checks") compress noeqlines replace

*
*Table B4. Average treatment effects
*Panel A.
eststo clear
eststo: reg dv_att i.group
eststo: reg dv_att i.group $demo_st2 i.victim_cartel
eststo: reg dv_att i.group##ib1.manip_check if group<8
eststo: reg dv_att i.group##ib1.manip_check $demo_st2 i.victim_cartel if group<8
esttab using "~TableB4_A.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) title("TableB4. Study 2 - Average treatment effects") wide compress noeqlines replace 
*Effects on standardized DV
eststo clear
reg st_dv_att i.group
eststo: margins, dydx(group) post
reg st_dv_att i.group $demo_st2 i.victim_cartel
eststo: margins, dydx(group) post
reg st_dv_att i.group##ib1.manip_check if group<8
eststo: margins, dydx(group) at(manip_check==1) post
reg st_dv_att i.group##ib1.manip_check $demo_st2 i.victim_cartel if group<8
eststo: margins, dydx(group) at(manip_check==1) post
esttab using "~TableB4_Ast.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) wide compress noeqlines replace 
*Panel B. Effects of info vs. civilians
eststo clear
reg dv_att ib2.group
eststo: margins, dydx(4.group 5.group) post
reg dv_att ib2.group $demo_st2 i.victim_cartel
eststo: margins, dydx(4.group 5.group) post
reg dv_att ib2.group##ib1.manip_check if group<8
eststo: margins, dydx(4.group 5.group) at(manip_check==1) post
reg dv_att ib2.group##ib1.manip_check $demo_st2 i.victim_cartel if group<8
eststo: margins, dydx(4.group 5.group) at(manip_check==1) post
esttab using "~TableB4_B.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) wide compress noeqlines replace 
*Effects on standardized DV
eststo clear
reg st_dv_att ib2.group
eststo: margins, dydx(4.group 5.group) post
reg st_dv_att ib2.group $demo_st2 i.victim_cartel
eststo: margins, dydx(4.group 5.group) post
reg st_dv_att ib2.group##ib1.manip_check if group<8
eststo: margins, dydx(4.group 5.group) at(manip_check==1) post
reg st_dv_att ib2.group##ib1.manip_check $demo_st2 i.victim_cartel if group<8
eststo: margins, dydx(4.group 5.group) at(manip_check==1) post
esttab using "~TableB4_Bst.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) wide compress noeqlines replace 

*
*Table B5. Average treatment effects by correct/incorrect recall
*no covariates
eststo clear
reg dv_att i.group##i.manip_check if group<8
eststo: margins, dydx(group) at(manip_check==0) post // wrong
reg dv_att i.group##i.manip_check if group<8
eststo: margins, dydx(group) at(manip_check==1) post // correct
esttab using "~TableB5a.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01)  scalars (r2) title("Average marginal effects by correct recall - no covariates") wide compress noeqlines replace
*with covariates
eststo clear
reg dv_att i.group##i.manip_check $demo_st2 i.victim_cartel if group<8
eststo: margins, dydx(group) at(manip_check==0) post // wrong
reg dv_att i.group##i.manip_check $demo_st2 i.victim_cartel if group<8
eststo: margins, dydx(group) at(manip_check==1) post // correct
esttab using "~TableB5b.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01)  scalars (r2) title("Average marginal effects by correct recall - with covariates") wide compress noeqlines replace
 
*
*Table B6. Interactions with self-reported victimization
eststo clear
eststo: reg dv_att i.group##i.victim_cartel
eststo: reg dv_att i.group##i.victim_cartel $demo_st2
eststo: reg dv_att i.group##i.victim_cartel##ib1.manip_check if group<8
eststo: reg dv_att i.group##i.victim_cartel##ib1.manip_check $demo_st2 if group<8
esttab using "~TableB6.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) title("TableB6. Interactions with victimization") wide compress noeqlines replace 

*
*Table B7. Interactions with homicide rate at respondents’ municipality of residence (Study 2)
eststo clear
eststo: reg dv_att i.group##c.hom_1317_pop_w
eststo: reg dv_att i.group##c.hom_1317_pop_w $demo_st2
esttab using "~TableB7.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) wide compress noeqlines replace 

*
*Table B8. Interactions with cartel presence at respondents’ municipality of residence (Study 2)
*Panel A. Cartel presence=continuous var
eststo clear
eststo: reg dv_att i.group##c.cartel_total2017
eststo: reg dv_att i.group##c.cartel_total2017 $demo_st2
esttab using "~TableB8_panelA.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) wide compress noeqlines replace 
*Panel B. Cartel presence=categorical var
eststo clear
eststo: reg dv_att i.group##i.cartel3
eststo: reg dv_att i.group##i.cartel3 $demo_st2
esttab using "~TableB8_panelB.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) wide compress noeqlines replace 

*
*Table B9. Treatment effects by area of residence (North vs. other areas)
gen north = 0 if regions!=.
replace north = 1 if regions==1 | regions==2
label de north 1"north east/north west" 0"other region"
label val north north
*Panel A
eststo clear
eststo: reg dv_att i.group##i.north 
eststo: reg dv_att i.group##i.north i.female age10 ib2.ed_level5 trust_army01 
eststo: reg dv_att i.group##i.north  if manip_check==1 & group<8
eststo: reg dv_att i.group##i.north i.female age10 ib2.ed_level5 trust_army01 if manip_check==1 & group<8
esttab using "~TableB9A.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) wide compress noeqlines replace 
*Panel B. marginal effects
*living in the north
eststo clear
reg dv_att i.group##i.north
eststo, title("(1)"): margins 1.north, dydx(2.group 3.group) post
reg dv_att i.group##i.north i.female age10 ib2.ed_level5 trust_army01
eststo, title("(2)"): margins 1.north, dydx(2.group 3.group) post
reg dv_att i.group##i.north  if manip_check==1 & group<8
eststo, title("(3)"): margins 1.north, dydx(2.group 3.group) post
reg dv_att i.group##i.north i.female age10 ib2.ed_level5 trust_army01 if manip_check==1 & group<8
eststo, title("(4)"): margins 1.north, dydx(2.group 3.group) post
esttab using "~TableB9_panelB_north.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) wide compress noeqlines replace 
*living in other regions
eststo clear
reg dv_att i.group##i.north
eststo, title("(1)"): margins 0.north, dydx(2.group 3.group) post
reg dv_att i.group##i.north i.female age10 ib2.ed_level5 trust_army01
eststo, title("(2)"): margins 0.north, dydx(2.group 3.group) post
reg dv_att i.group##i.north  if manip_check==1 & group<8
eststo, title("(3)"): margins 0.north, dydx(2.group 3.group) post
reg dv_att i.group##i.north i.female age10 ib2.ed_level5 trust_army01 if manip_check==1 & group<8
eststo, title("(4)"): margins 0.north, dydx(2.group 3.group) post
esttab using "~TableB9_panelB_other.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) wide compress noeqlines replace

*

*Table B10. Treatment effects by area of residence (presence of Zetas vs. other area) 
gen zetas = 0 if region!=.
replace zetas = 1 if DB1_1==2 | DB1_1==5 | DB1_1==12 | DB1_1==14 | DB1_1==19 | DB1_1==20 | DB1_1==28 | DB1_1==29 | DB1_1==30
label de zetas 1"Zetas" 0"other area"
label val zetas zetas
*Panel A
eststo clear
eststo: reg dv_att i.group##i.zetas 
eststo: reg dv_att i.group##i.zetas i.female age10 ib2.ed_level5 trust_army01 
eststo: reg dv_att i.group##i.zetas  if manip_check==1 & group<8
eststo: reg dv_att i.group##i.zetas i.female age10 ib2.ed_level5 trust_army01 if manip_check==1 & group<8
esttab using "~TableB10a.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) wide compress noeqlines replace 
*Panel B. marginal effects
*living in area with presence of zetas
eststo clear
reg dv_att i.group##i.zetas
eststo, title("(1)"): margins 1.zetas, dydx(2.group 3.group) post
reg dv_att i.group##i.zetas i.female age10 ib2.ed_level5 trust_army01
eststo, title("(2)"): margins 1.zetas, dydx(2.group 3.group) post
reg dv_att i.group##i.zetas  if manip_check==1 & group<8 // REDO ADDING TRIPLE INTERACTION
eststo, title("(3)"): margins 1.zetas, dydx(2.group 3.group) post
reg dv_att i.group##i.zetas i.female age10 ib2.ed_level5 trust_army01 if manip_check==1 & group<8
eststo, title("(4)"): margins 1.zetas, dydx(2.group 3.group) post
esttab using "~TableB10_panelB_zetas.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) wide compress noeqlines replace 
*living in other areas
eststo clear
reg dv_att i.group##i.zetas
eststo, title("(1)"): margins 0.zetas, dydx(2.group 3.group) post
reg dv_att i.group##i.zetas i.female age10 ib2.ed_level5 trust_army01
eststo, title("(2)"): margins 0.zetas, dydx(2.group 3.group) post
reg dv_att i.group##i.zetas  if manip_check==1 & group<8
eststo, title("(3)"): margins 0.zetas, dydx(2.group 3.group) post
reg dv_att i.group##i.zetas i.female age10 ib2.ed_level5 trust_army01 if manip_check==1 & group<8
eststo, title("(4)"): margins 0.zetas, dydx(2.group 3.group) post
esttab using "~TableB10_panelB_other.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) wide compress noeqlines replace

*
*Figure B1. Effects of human costs by presence of cartels (categorical var.) in municipality of residence
*civilians
eststo clear
reg dv_att i.group##i.cartel3 $demo_st2
eststo all: margins cartel3, dydx(2.group) post
*civilians - correct recall
reg dv_att i.group##i.cartel3##ib1.manip_check $demo_st2 if group<8
eststo correct: margins cartel3, dydx(2.group) at(manip_check==1) post
*graph
coefplot all correct, vert yline(0, lpattern(dash) lcolor(gs10)) ///
name(figB1a, replace) recast(scatter) ///
graphregion(color(white)) level(90) title("Effect of human costs among civilians") ///
ytitle("Effect on support for militarization") xtitle("Cartel presence")
*cartel
eststo clear
reg dv_att i.group##i.cartel3 $demo_st2
eststo all: margins cartel3, dydx(3.group) post
*cartel - correct recall
reg dv_att i.group##i.cartel3##ib1.manip_check $demo_st2 if group<8
eststo correct: margins cartel3, dydx(3.group) at(manip_check==1) post
*graph
coefplot all correct, vert yline(0, lpattern(dash) lcolor(gs10)) ///
name(figB1b, replace) recast(scatter) ///
graphregion(color(white)) level(90) title("Effect of human costs among cartel members") ///
ytitle("") xtitle("Cartel presence")
*final figure
graph combine figB1a figB1b, graphregion(color(white)) name(figB1_comb)

*
*Figure B2. Effect of successful operation by homicide rate and presence of drug cartels
*homicide rate
reg dv_att ib8.group##c.hom_1317_pop_w $demo_st2
margins, dydx(1.group) at(hom_1317_pop_w=(0.70(0.48)4.55))
marginsplot, yline(0, lpattern(dash) lcolor(gs10)) level(90) recastci(rline) ciopts(lpattern(dash)) recast(line) ///
graphregion(color(white)) ///
ytitle("Effects on support for militarization") ///
xtitle("Homicide rate (from 10th to 90th pctile)") ///
title("Effects by homicide rate") name(figureB1_A, replace)
*cartel presence
reg dv_att ib8.group##c.cartel_total2017 $demo_st2
margins, dydx(1.group) level(90) at(cartel_total2017=(0(1)9))
marginsplot, yline(0, lpattern(dash) lcolor(gs10)) level(90) recastci(rline) ciopts(lpattern(dash)) recast(line) ///
graphregion(color(white)) ///
ytitle("") ///
xtitle("Number of drug cartels in municipality of residence") ///
title("Effects by cartel presence") name(figureB1_B, replace)
*combined
graph combine figureB1_A figureB1_B, graphregion(color(white)) ///
title("Effect of successful operation (Group 1) vs. empty condition (Group 8)")


*******************
*Figure 3: Effects of human costs by homicide rate and presence of cartels in municipality of residence

*BY HOMICIDE RATE
*Civilians
eststo clear
*all
reg dv_att i.group##c.hom_1317_pop_w $demo_st2
eststo mar1A: margins, dydx(2.group) at(hom_1317_pop_w=(0.70(0.48)4.55)) post
*correct recall
reg dv_att i.group##c.hom_1317_pop_w##ib1.manip_check $demo_st2 if group<8
eststo mar1B: margins, dydx(2.group) at(hom_1317_pop_w=(0.70(0.48)4.55) manip_check==1) post
*graph
coefplot (mar1B, recast(line) lwidth(*1) lcolor(ebblue) lpattern(dash) ciopts(lpattern(dash) lcolor(ebblue) recast(rline))) ///
(mar1A, citop recast(line) lwidth(*1) lcolor(dknavy) ciopts(lpattern(solid) lcolor(dknavy) recast(rline))), ///
yline(0, lpattern(shortdash) lcolor(gs10)) vert citop ///
name(fig3A, replace)  graphregion(color(white)) level(90) title("Effect of human costs among civilians") ///
yscale(range(-.2(.1).2)) ylabel(-.2(.1).2) ///
ytitle("Effect on support for militarization") xtitle("Homicide rate (from 10th to 90th pctile)")

*Cartel
eststo clear
*all
reg dv_att i.group##c.hom_1317_pop_w $demo_st2
eststo mar2A: margins, dydx(3.group) at(hom_1317_pop_w=(0.70(0.48)4.55)) post
*correct
reg dv_att i.group##c.hom_1317_pop_w##ib1.manip_check $demo_st2 if group<8
eststo mar2B: margins, dydx(3.group) at(hom_1317_pop_w=(0.70(0.48)4.55) manip_check==1) post
*graph
coefplot (mar2B, recast(line) lpattern(dash) lwidth(*) lcolor(ebblue) ciopts(lpattern(dash) lcolor(ebblue) recast(rline))) ///
(mar2A, citop recast(line) lcolor(dknavy) lwidth(*1) ciopts(lpattern(solid) lcolor(dknavy) recast(rline))), ///
yline(0, lpattern(shortdash) lcolor(gs10)) vert citop ///
name(fig3B, replace)  graphregion(color(white)) level(90) title("Effect of human costs among cartel members") ///
yscale(range(-.2(.1).2)) ylabel(-.2(.1).2) ///
ytitle("") xtitle("Homicide rate (from 10th to 90th pctile)")

*BY CARTEL PRESENCE
*civilians
eststo clear
*all
reg dv_att i.group##c.cartel_total2017 $demo_st2
eststo mar3A: margins, dydx(2.group) at(cartel_total2017=(0(1)9)) post
*correct
reg dv_att i.group##c.cartel_total2017##ib1.manip_check $demo_st2 if group<8
eststo mar3B: margins, dydx(2.group) at(cartel_total2017=(0(1)9) manip_check==1) post
*graph
coefplot (mar3B, recast(line) lpattern(dash) lwidth(*) lcolor(ebblue) ciopts(lpattern(dash) lcolor(ebblue) recast(rline))) ///
(mar3A, citop recast(line) lcolor(dknavy) lwidth(*1) ciopts(lpattern(solid) lcolor(dknavy) recast(rline))), ///
yline(0, lpattern(shortdash) lcolor(gs10)) vert citop ///
name(fig3C, replace)  graphregion(color(white)) level(90) title("Effect of human costs among civilians") ///
yscale(range(-.2(.1).2)) ylabel(-.2(.1).2) ///
ytitle("Effect on support for militarization") xtitle("Cartel presence (number of cartels)")

*cartel
eststo clear
*all
reg dv_att i.group##c.cartel_total2017 $demo_st2
eststo mar4A: margins, dydx(3.group) at(cartel_total2017=(0(1)9)) post
*correct
reg dv_att i.group##c.cartel_total2017##ib1.manip_check $demo_st2 if group<8
eststo mar4B: margins, dydx(3.group) at(cartel_total2017=(0(1)9) manip_check==1) post
*graph
coefplot (mar4B, recast(line) lpattern(dash) lwidth(*) lcolor(ebblue) ciopts(lpattern(dash) lcolor(ebblue) recast(rline))) ///
(mar4A, citop recast(line) lcolor(dknavy) lwidth(*1) ciopts(lpattern(solid) lcolor(dknavy) recast(rline))), ///
yline(0, lpattern(shortdash) lcolor(gs10)) vert citop ///
name(fig3D, replace)  graphregion(color(white)) level(90) title("Effect of human costs among cartel members") ///
yscale(range(-.2(.1).2)) ylabel(-.2(.1).2) ///
ytitle("") xtitle("Cartel presence (number of cartels)")

*final figure
graph combine fig3A fig3B fig3C fig3D, graphregion(color(white))



